<template>
  <div class="main">
    <Header/>
      <div class="content">
        <div class="item" @click="$router.push(`/goods/${index}`)" v-for="(item,index) in dataList" :key="index">
          <div class="img-box">
            <img width="100%" height="150px" :src="item.img" alt="">
            <div class="img-text">{{item.imgText}}</div>
          </div>
          <div class="footer">
            <div class="footer-top">
              <span class="new-price">￥{{item.newPrice}}</span>
              <span class="old-price">￥{{item.oldPrice}}</span>
            </div>
            <div class="footer-bottom">
              <span>{{item.state}}</span>
              <span>剩{{item.num}}件</span>
            </div>
          </div>
        </div>
        <mt-button @click="load" class="mint-button mint-button--danger mint-button--large is-plain">加载更多</mt-button>
        
      </div>
  </div>
</template>

<script>
import Header from '../Header/Header.vue'
export default {
  components: { Header },
  data(){
    return {
      dataList:[
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:60
        },
      ]
    }
  },
  methods:{
    load(){
      this.dataList.push(
        {
          img:'../../../static/huawei.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:2
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:2
        },
        {
          img:'../../../static/img/apple.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:3
        },
        {
          img:'../../../static/huawei.jpg',
          imgText:'华为(HUAWEI)荣耀6Plus16G双4G版',
          newPrice:2195,
          oldPrice:2490,
          state:'热卖中',
          num:1
        },
      )
    }
  }
}
</script>

<style scoped>
.content{
  margin-top: 6vh;
  margin-bottom: 8vh;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  background: #eee;
}
.item{
  margin: 10px 2%;
  width: 46%;
}

.img-box{
  position: relative;
  font-size: 0px;
}
.img-text{
    position: absolute;
    top: 40%;
    font-size: 13px;
    text-align: left;
    font-weight: bold
}
.footer{
    background: ghostwhite;;
    padding: 4px;
    text-align: left;
}
.new-price{
  color: red;
}
.old-price{
  color: #999;
  font-size: 12px;
  text-decoration: line-through;
}
.footer-bottom{
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 12px;
}

.mint-button{
  margin: auto;
  width: 98%;
  margin-top: 10px;
}
</style>